/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package negocio;

import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Temporal;
import static javax.persistence.TemporalType.DATE;

/**
 *
 * @author diego
 */
@Entity
public class TransaccionVentas implements Serializable {
    @Id    
    @Column(name="TRANSACCIONVENTAS_ID")
    private Integer id;    
    
    @ManyToOne
    @JoinColumn(name="FUNCION_ID")
    private Funcion funcion;
    
    @OneToMany(mappedBy="transaccionVentas")
    private Set<Ticket> tickets;
    
    @Temporal(DATE)
    private Date fecha;
    
  
    

    public TransaccionVentas() {
    }
    public TransaccionVentas(Funcion unaFuncion, Date fecha ) {
        this.funcion = unaFuncion;
        this.fecha = fecha;
        this.tickets = new HashSet();        
    }
    public Integer getId() {
        return id;
    }
    public void setId(Integer id) {
        this.id = id;
    }
    public Funcion getUnaFuncion() {
        return funcion;
    }
    public void setUnaFuncion(Funcion unaFuncion) {
        this.funcion = unaFuncion;
    }
    public Set<Ticket> getTickets() {
        return tickets;
    }
    public void setTickets(Set<Ticket> tickets) {
        this.tickets = tickets;
    }
    public Date getFecha() {
        return fecha;
    }
    public void setFecha(Date fecha) {
        this.fecha = fecha;
    }

    public void agregarTicket(Funcion unaFuncion, Butaca unaButaca, String nro, Double precio, Usuario unUsuario){
        this.tickets.add(new Ticket(unaFuncion,unaButaca,nro,precio,unUsuario,this));                
    }
    
    public int ticketsVendidos(){
        return this.tickets.size();
    }
}
